using System;
using System.Data;
using System.Data.SqlClient;


/// <summary>
/// Summary description for SQLServerComponent
/// </summary>
public partial class SQLServerComponent
{
    public DataTable GetProvinces(string countryName)
    {
        errorMessage = "";
        DataTable dataTable = new DataTable();
        try
        {
            OpenConnection();
            sqlCommand = new SqlCommand();
            sqlCommand.CommandText = "SPShowProvinces";
            sqlCommand.Connection = sqlConnection;
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.Parameters.AddWithValue("@CountryName", countryName);
            SqlDataAdapter sqlDataAdapter =  new SqlDataAdapter(sqlCommand);
            sqlDataAdapter.Fill(dataTable);
            sqlDataAdapter.Dispose();
            CloseConnection();
        }
        catch (SqlException sql)
        {
            errorCode = sql.Number;
            errorMessage = sql.Message;
        }
        catch (Exception ex)
        {
            errorMessage = ex.Message;

        }
        return dataTable;
    }
    

}
